feat(platform): include jobKey in LLM Gateway trace baggage#1731
feat(platform): include jobKey in LLM Gateway trace baggage#1731RunnanJia wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the platform LLM trace context propagation to include jobKey in the x-uipath-tracebaggage header, enabling LLM Gateway spans to be attributed to the originating job without requiring callers to manually inject this baggage entry.
Changes:
- Add
jobKeyfromUiPathConfig.job_keyto the emittedx-uipath-tracebaggageentries when trace context headers are enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if job_key := UiPathConfig.job_key: | ||
| baggage_parts.append(f"jobKey={job_key}") |
089244b to
a01bb31
Compare
🚨 Heads up:
|
build_trace_context_headers emits folderKey/agentId/processKey but omits jobKey, even though UiPathConfig.job_key is available. LLM Gateway now builds the model-call span from this baggage, so without jobKey the span cannot be attributed to the originating job. Callers currently work around this by hand-injecting jobKey via extra_baggage; emitting it natively fixes it once for every caller. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
a01bb31 to
f3b7585
Compare
|
| if process_uuid := UiPathConfig.process_uuid: | ||
| baggage_parts.append(f"processKey={process_uuid}") | ||
| if job_key := UiPathConfig.job_key: | ||
| baggage_parts.append(f"jobKey={job_key}") |
There was a problem hiding this comment.
do we need this as part of baggage. I saw that on other flows this is pass as a independent header #1739 (how is also licensingRefId)



Why
build_trace_context_headers(uipath/platform/chat/llm_trace_context.py) propagatesfolderKey,agentId, andprocessKeyintox-uipath-tracebaggage, but notjobKey— even thoughUiPathConfig.job_keyis available. LLM Gateway now builds the model-call span from this baggage (see the LLMGateway span work), so a missingjobKeymeans the span can't be attributed to the originating job.Today callers compensate by hand-injecting
jobKeythroughextra_baggage(e.g. uipath-agents-python). Emitting it natively here fixes it once for every caller and lets those workarounds be removed.What
One addition in
build_trace_context_headers, mirroring the existingprocessKeyblock:Gated by the existing
EnableTraceContextHeadersflag like the rest of the function; no behavior change when the flag is off.Note
Callers that already inject
jobKeyviaextra_baggagewill momentarily send it twice in the comma-joined header; the LLM Gateway baggage parser is last-write-wins, so this is harmless. Those callers can drop the manual injection once this ships.🤖 Generated with Claude Code